﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Whir_System_Module_Publish_PublishSetting : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断
       
        if (!IsPostBack)
        {
            //string xmlPath = Server.MapPath(Whir.Common.Settings.GetString("XmlPath") + "PublishConfig.xml");
            string xmlPath = Server.MapPath("~/" + Whir.Common.Settings.GetString("XmlPath") + "PublishConfig.xml");
            Type type = typeof(Whir.Config.Model.PublishConfig);
            Whir.Config.Model.PublishConfig model = (Whir.Config.Model.PublishConfig)Whir.Common.XmlHelper.DeserializeObject(xmlPath, type);         //反序列化

            rbListHtml.SelectedValue = model.ListHtml;
            rbSavePath.SelectedValue = model.SavePath;
            rbContentHtml.SelectedValue = model.ContentHtml;
            txtDir.Text = model.ContentDir;
            txtFileName.Text = model.ContentFileName;
            dropFileExt.SelectedValue = model.ContentFileExt;
            rbCreateHtmlType.SelectedValue = model.CreateHtmlType;
        }
    }
    //修改
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Whir.Config.Model.PublishConfig model = new Whir.Config.Model.PublishConfig();

        model.ListHtml = rbListHtml.SelectedItem.Value;
        model.SavePath = rbSavePath.SelectedItem.Value;
        model.ContentHtml = rbContentHtml.SelectedItem.Value;
        model.ContentDir = txtDir.Text;
        model.ContentFileName = txtFileName.Text;
        model.ContentFileExt = dropFileExt.SelectedItem.Value;
        model.CreateHtmlType = rbCreateHtmlType.SelectedItem.Value;

        //string xmlPath = Server.MapPath(Whir.Common.Settings.GetString("XmlPath") + "PublishConfig.xml");
        string xmlPath = Server.MapPath("~/" + Whir.Common.Settings.GetString("XmlPath") + "PublishConfig.xml");
        Type type = typeof(Whir.Config.Model.PublishConfig);
        Whir.Common.XmlHelper.SerializerObject(xmlPath, type, model);               //序列化

        this.OLAdd();    //操作日志
    }

    //操作日志
    protected void OLAdd()
    {
        Whir.Log.Model.Whir_OperateLog model = new Whir.Log.Model.Whir_OperateLog();
        model.title = "发布管理信息";
        model.operateType = 2;      //修改
        model.operateResult = true;
        model.operateDesc = "修改发布设置信息";

        Whir.Log.OperateLog.Add(model);
    }
}
